package com.palfund.pagertabstrip;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;


/**
 * A simple {@link Fragment} subclass.
 */
public class BlankFragment extends Fragment {

    private int mTabIndex;

    public static BlankFragment newInstance(int tabIndex) {
        BlankFragment fragment = new BlankFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("tabIndex", tabIndex);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Log.i("BlankFragment", "---onAttach()--->context" + mTabIndex);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("BlankFragment", "---onCreate()--->" + mTabIndex);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
            savedInstanceState) {
        Log.i("BlankFragment", "---onCreateView()--->" + mTabIndex);
        return inflater.inflate(R.layout.fragment_blank, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ListView listView = (ListView) view.findViewById(R.id.listView);
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 60; i++) {
            list.add(mTabIndex + "item" + i);
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout
                .simple_list_item_1, list);
        listView.setAdapter(adapter);
        Log.i("BlankFragment", "---onViewCreated()--->" + mTabIndex);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.i("BlankFragment", "---onActivityCreated()--->" + mTabIndex);
    }

    @Override
    public void onStart() {
        super.onStart();
        Log.i("BlankFragment", "---onStart()--->" + mTabIndex);
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.i("BlankFragment", "---onResume()--->" + mTabIndex);
    }

    @Override
    public void onPause() {
        super.onPause();
        Log.i("BlankFragment", "---onPause()--->" + mTabIndex);
    }

    @Override
    public void onStop() {
        super.onStop();
        Log.i("BlankFragment", "---onStop()--->" + mTabIndex);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.i("BlankFragment", "---onDestroyView()--->" + mTabIndex);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("BlankFragment", "---onDestroy()--->" + mTabIndex);
    }

    @Override
    public void onDetach() {
        super.onDetach();
        Log.i("BlankFragment", "---onDetach()--->" + mTabIndex);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mTabIndex = getArguments().getInt("tabIndex");
        Log.i("BlankFragment", "---onAttach()--->activity" + mTabIndex);
    }

    public BlankFragment() {
        Log.i("BlankFragment", "---BlankFragment()--->");
    }


}
